// 数组中出现一个数字的次数超过数组长度一半，请找出这个数字

function getmaxnumber(arr: number[]) {
  let tmp1: { [num: number]: number } = {}
  for (let i of arr) {
    tmp1[i] = tmp1[i] ? tmp1[i] : 0
    tmp1[i]++
  }
  let tmp = 0
  let tmpv = 0
  for (let v in tmp1) {
    if (tmp < tmp1[v]) {
      tmp = tmp1[v]
      tmpv = Number(v)
    }

  }
  return tmpv
}

console.log(getmaxnumber([1, 2, 3, 4, 5, 6, 4, 54, 5, 4, 54, 5, 45, 4, 54, 5, 4, 54, 5]))

